package com.web.app.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author JMLF
 * @date 2022-09-22
 */
@Component
//扫描dao接口
@MapperScan("com.web.app.dao")
public class PageConfig {

    @Bean
    public static MybatisPlusInterceptor getPageInterceptor(){
        //申明 MybatisPlusInterceptor 的变量
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //向变量里添加 PaginationInnerInterceptor 告诉 PaginationInnerInterceptor 需要的数据库是DbType.MYSQL
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return mybatisPlusInterceptor;
    }

}
